
import type { placeholderSign } from 'element-plus/es/components/table-v2/src/private';
<template>
  <div class="app-container">
    <div>
      <el-row :gutter="10">
        <el-col :span="6" :xs="24" :lg="24">
          <div class="bgwhite plr20 ptb20 radius10 flex-col">
            <div class="justify-between w100p">
              <div class="clr3c4 bold ft26">{{ formLabelAlign.type == 'ruleAdd' ? '新增' : '编辑' }}</div>
              <div class="clr9fa align-center pointer" @click="back()">
                <el-icon>
                  <Back />
                </el-icon>
                <span class="ml5">返回上一頁</span>
                <!-- <span class="plr20">|</span>
                <el-icon class="clr3c4">
                  <View />
                </el-icon>
                <span class="ml5 clr3c4">查看</span>
                <span class="plr20">|</span>

                <el-icon class="red">
                  <Delete />
                </el-icon>
                <span class="red ml5">刪除</span> -->
              </div>
            </div>
            <div class="mt40">
              <!-- 充值规则编辑 -->
              <template v-if="formLabelAlign.type == 'ruleEdit'">
                <el-form :label-position="labelPosition" label-width="auto" :model="formLabelAlign" style="max-width: 600px">
                  <el-form-item label="ID:">
                    <el-input v-model="formLabelAlign.formInfo.id" disabled style="width: 380px;" placeholder="請輸入標題" />
                  </el-form-item>
                  <el-form-item label="價格:" required>
                    <el-input v-model="formLabelAlign.formInfo.money" placeholder="請輸入價格" />
                  </el-form-item>
                  <el-form-item label="贈送金幣:">
                    <el-input v-model="formLabelAlign.formInfo.votes" style="width: 380px;" placeholder="請輸入贈送金幣" />
                  </el-form-item>
                  <el-form-item label="創建時間:">
                    <el-input v-model="formLabelAlign.formInfo.created_at" disabled style="width: 380px;" placeholder="請輸入標題" />
                  </el-form-item>
                  <el-form-item label="更新時間:">
                    <el-input v-model="formLabelAlign.formInfo.updated_at" disabled style="width: 380px;" placeholder="請輸入標題" />
                  </el-form-item>
                </el-form>
              </template>

              <!-- 查看 -->
              <!-- <p>----查看</p>
              <el-form :label-position="labelPosition" label-width="auto" :model="formLabelAlign"
                style="max-width: 600px">
                <el-form-item label="ID:">
                  <el-input v-model="formLabelAlign.name" disabled style="width: 380px;" placeholder="請輸入標題" />
                </el-form-item>
                <el-form-item label="價格:" required>
                  <el-input v-model="formLabelAlign.region" disabled placeholder="請輸入消息内容" />
                </el-form-item>
                <el-form-item label="贈送金幣:">
                  <el-input v-model="formLabelAlign.name" disabled style="width: 380px;" placeholder="請輸入標題" />
                </el-form-item>
                <el-form-item label="創建時間:">
                  <el-input v-model="formLabelAlign.name" disabled style="width: 380px;" placeholder="請輸入標題" />
                </el-form-item>
                <el-form-item label="更新時間:">
                  <el-input v-model="formLabelAlign.name" disabled style="width: 380px;" placeholder="請輸入標題" />
                </el-form-item>
              </el-form> -->
              <!-- 充值规则新增 -->
              <template v-if="formLabelAlign.type == 'ruleAdd'">
                <el-form :label-position="labelPosition" label-width="auto" :model="formLabelAlign.formInfo" style="max-width: 600px">
                  <el-form-item label="價格:" required>
                    <el-input v-model="formLabelAlign.formInfo.money" placeholder="請輸入價格" />
                  </el-form-item>
                  <el-form-item label="贈送金幣:" required>
                    <el-input v-model="formLabelAlign.formInfo.votes" style="width: 380px;" placeholder="請輸入贈送金幣" />
                  </el-form-item>
                </el-form>
              </template>
              <!-- 提现编辑 -->
              <template v-if="formLabelAlign.type == 'withdraw'">
                <el-form :label-position="labelPosition" label-width="auto" :model="formLabelAlign" style="max-width: 600px">
                  <el-form-item label="ID:">
                    <el-input v-model="formLabelAlign.formInfo.id" disabled style="width: 380px;" placeholder="請輸入標題" />
                  </el-form-item>
                  <el-form-item label="用戶訊息:">
                    <el-input v-model="formLabelAlign.formInfo.uid" disabled placeholder="請輸入消息内容" />
                  </el-form-item>
                  <el-form-item label="提現金額:">
                    <el-input v-model="formLabelAlign.formInfo.money" disabled style="width: 380px;" placeholder="請輸入標題" />
                  </el-form-item>
                  <el-form-item label="手机号:">
                    <el-input v-model="formLabelAlign.formInfo.user.phone" disabled style="width: 380px;" placeholder="請輸入標題" />
                  </el-form-item>
                  <el-form-item label="審核:">
                    <el-radio-group v-model="formLabelAlign.formInfo.state" class="ml-4">
                      <el-radio :value="1" size="large"> 同意</el-radio>
                      <el-radio :value="2" size="large">拒絕</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="拒絕原因:">
                    <el-input v-model="formLabelAlign.formInfo.reason" style="width: 380px;" placeholder="請輸入拒絕原因" />
                  </el-form-item>
                  <el-form-item label="打款狀態:">
                    <el-radio-group v-model="formLabelAlign.formInfo.is_refund" class="ml-4">
                      <el-radio :value="1" size="large">已打款</el-radio>
                      <el-radio :value="0" size="large">未打款</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-form>
              </template>

              <div class="mt40 mb15 flex-cen ">
                <div class="align-center">
                  <el-button class="btn1" @click="reset()">重置</el-button>
                  <el-button class="btn2" @click="submit()">提交</el-button>
                </div>

              </div>
            </div>


          </div>

        </el-col>



      </el-row>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router';
import type { FormProps } from 'element-plus'
import { editWithdraw, chargeRuleAdd, chargeRuleEdit } from '@/api/finance.js'
const route = useRoute()
onMounted(() => {
  formLabelAlign.type = `${route.query.type}`
  if (route.query.type == 'withdraw') {
    formLabelAlign.formInfo = JSON.parse(route.query.row)
    console.log('提现审核数据', JSON.parse(route.query.row))
    return
  }
  formLabelAlign.formInfo = route.query

  if (route.query.type == 'ruleAdd') {
    formLabelAlign.formInfo.money = ''
    formLabelAlign.formInfo.votes = ''
  }

})
const radio1 = ref('1')
const labelPosition = ref<FormProps['labelPosition']>('right')

const formLabelAlign = reactive({
  formInfo: {},
  type: ''
})
const submit = () => {
  if (route.query.type == 'withdraw') {
    editWithdraw({
      id: formLabelAlign.formInfo.id,
      state: formLabelAlign.formInfo.state,
      is_refund: formLabelAlign.formInfo.is_refund,
      reason: formLabelAlign.formInfo.reason

    }).then(() => {
      back()
    })
  }
  if (route.query.type == 'ruleAdd') {
    chargeRuleAdd({
      money: formLabelAlign.formInfo.money,
      votes: formLabelAlign.formInfo.votes
    }).then(() => {
      back()
    })
  }
  if (route.query.type == 'ruleEdit') {
    chargeRuleEdit({
      id: formLabelAlign.formInfo.id,
      money: formLabelAlign.formInfo.money,
      votes: formLabelAlign.formInfo.votes
    }).then(() => {
      back()
    })
  }
}
const reset = () => {

}
const router = useRouter()
const back = () => {
  router.back()
}
</script>
<style scoped >
:deep(.el-upload--picture-card) {
  background-color: transparent;
  border: none;
}

:deep(.el-input__wrapper) {
  /* align-items: start; */
}

:deep(.el-input) {
  box-shadow: none;
}
</style>